package com.ovopark.firecar.activity

import android.text.Editable
import android.util.Log
import android.widget.EditText
import android.widget.RelativeLayout
import android.widget.TextView
import com.ovopark.firecar.R
import com.ovopark.firecar.utils.SharedPreferencesUtils

class AddServiceActivity : BaseActivity() {
    lateinit var etServiceName : EditText
    lateinit var etIpAddress : EditText
    lateinit var etPort : EditText
    lateinit var etUsername : EditText
    lateinit var etPassword : EditText
    lateinit var tvConfirmAdd : TextView
    lateinit var rlReturn : RelativeLayout
    override fun initView() {
        super.initView()
        setContentView(R.layout.activity_add_service)
        rlReturn = findViewById(R.id.rl_return)
        etServiceName = findViewById(R.id.et_service_name)
        etIpAddress = findViewById(R.id.et_ip_address)
        etPort = findViewById(R.id.et_port)
        etUsername = findViewById(R.id.et_username)
        etPassword = findViewById(R.id.et_password)
        tvConfirmAdd = findViewById(R.id.tv_confirm_add)

        tvConfirmAdd.setOnClickListener {
            SharedPreferencesUtils.getInstance(sharePreferenceName)!!.setParam(this, name,etServiceName.text.trim().toString())
            SharedPreferencesUtils.getInstance(sharePreferenceName)!!.setParam(this, ip,etIpAddress.text.trim().toString())
            SharedPreferencesUtils.getInstance(sharePreferenceName)!!.setParam(this, port,etPort.text.trim().toString())
            SharedPreferencesUtils.getInstance(sharePreferenceName)!!.setParam(this, username,etUsername.text.trim().toString())
            SharedPreferencesUtils.getInstance(sharePreferenceName)!!.setParam(this, password,etServiceName.text.trim().toString())
            finish()
        }

        rlReturn.setOnClickListener {
            finish()

        }

    }

    companion object{
        val sharePreferenceName : String = "addService"
        val name : String = "name"
        val ip : String = "ip"
        val port : String = "port"
        val username : String = "username"
        val password : String = "password"
    }
}